
#include "proc.h"

#define TYPE '*'
#define NUM 101

void Flushproc(double cur,double sum)
{
  
  char buffer[NUM];
  
  memset(buffer,0,sizeof(buffer));
  
  int rate = (int)cur / sum * 100;
  int i = 0;
  while(i < rate)
  {
    buffer[i] = TYPE;
    i++;
  }
  
  double n = cur / sum*100;

  static int cnt = 0;
  const char* lable = "|/-\\";
  int len = strlen(lable);
  cnt %= len;
  
  printf("[%-100s][%.1lf%%][%c]\r",buffer,n,lable[cnt]);
  cnt++;
  fflush(stdout);

}


void process_v1()
{
  char buffer[NUM];
  
  memset(buffer,0,sizeof(buffer));

  int cnt = 0;
  const char* lable = "|/-\\";
  int len = strlen(lable);

  while(cnt < NUM)
  {
    printf("[%-100s][%d%%][%c]\r",buffer,cnt,lable[cnt % len]);
    fflush(stdout);
		buffer[cnt] = TYPE;
    cnt++;
		usleep(50000);
  }

  printf("\n");
}
